<%@page import="cn.copera.kaka.utils.Sign"%>
<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<c:set var="ctxStatic" value="${pageContext.request.contextPath}/static" />
<!DOCTYPE html>
<html> 
<head> 
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" > 
    <title>分享</title> 
    <meta name="viewport" content="height = device-height, width=device-width, initial-scale=1, user-scalable=no">
    <link href="${ctxStatic}/jqmobile/jquery.mobile-1.4.3/jquery.mobile-1.4.3.min.css" rel="stylesheet"> 
    	<link rel="stylesheet" href="${ctxStatic}/kaka/css/ui-base.css">
        <link rel="stylesheet" href="${ctxStatic}/kaka/css/ui-box.css">
        <link rel="stylesheet" href="${ctxStatic}/kaka/css/ui-color.css">
		<link rel="stylesheet" href="${ctxStatic}/kaka/css/ui-res.css">
		<link rel="stylesheet" href="${ctxStatic}/kaka/css/ui-style.css">
		<link rel="stylesheet" href="${ctxStatic}/kaka/css/layout.css">
    
	<script src="${ctxStatic}/jquery/1.11.1/jquery-1.11.1.min.js"></script>
	<script src="${ctxStatic}/jqmobile/jquery.mobile-1.4.3/jquery.mobile-1.4.3.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){	
	var check = $("#cp1").val();
	if(parseInt($("#sc").val())>=parseInt($("#tc").val())){
	$.mobile.loading( 'show', {
		  text: "请及时认领"+check+"个卡点，或系统将在凌晨为您自动认领。",
		  textVisible: true,
		  theme: 'b',
		  textonly: true,
		  html: ""
		  });		
	setTimeout("hide()",5000);	
	}
	var message = $("#message").val();
	if(message!=""){
		$.mobile.loading( 'show', {
			  text: message,
			  textVisible: true,
			  theme: 'b',
			  textonly: true,
			  html: ""
			  });		
		setTimeout("hide()",5000);	
	}
});
function hide(){
	$.mobile.loading( "hide" );
}
</script>	
</head>
<% 
String shopid = request.getSession().getAttribute("shopid").toString();
String openid = request.getSession().getAttribute("openid").toString();
String serverUrl = request.getSession().getAttribute("serverUrl").toString();
String shopname = request.getSession().getAttribute("shopname").toString();
String shopimage = request.getSession().getAttribute("shopimage").toString();
String signature= Sign.getSignature(shopid, openid);
%>
<body class="um-vp bg-gray" ontouchstart>
<div data-role="page" data-theme="none">
        <div id="page_0" class="up ub ub-ver "  tabindex="0">
            <!--header开始-->
            <div id="header" class="uh c-m3 t-wh headerbg">
                <h1 class="hbg ulev0 ut-s tx-c headerPo" tabindex="0"><a class="btnBack" href="${ctx}/shopIndex/${shopid}-${openid}" data-ajax="false"></a><span   id="headtitle">${shop.shop_name}</span><a href="" class="textReport"></a></h1>
            </div>
           	<input type="hidden" value="${shopid}" name="shopid" id="shopid">
			<input type="hidden" value="${openid}" name="openid" id="openid">
			<input type="hidden" value="${serverUrl}" name="serverUrl" id="serverUrl">
			<input type="hidden" value="${shop.shop_name}" name="shopname" id="shopname">
			<input type="hidden" value="${shop.head_image}" name="shophead" id="shophead">
			<!--content开始-->
            <div id="content" class="contentC">
			    <div class="shopView borderBottom">
                	<a href="">
                	<c:choose>
                	<c:when test="${shop.head_image eq null or shop.head_image eq '无'}">
                	<div class="shopPic"><img src="${ctx}/images/logo_kaka.png"></div>
                	</c:when>
                	<c:otherwise>
                		<div class="shopPic"><img src="${serverUrl}${shop.head_image}"></div>
                		</c:otherwise>
                	</c:choose>	
						<div class="shopInfo">
							<ul class="infoList">
								<li class="tittle">${shop.shop_name}<c:if test="${shop.shop_name eq null}">无</c:if></li>
								<li class="text_info">${shop.address}<c:if test="${shop.address eq null}">无</c:if></li>
							</ul>
							
						</div></a>
                </div>
				<div class="shareBar">
						<span class="iconShareB"></span><span class="textS"> 分享${share.total_count}<c:if test="${share.total_count eq null}">0</c:if>次，获赠${share.presenter_count}<c:if test="${share.presenter_count eq null}">0</c:if>个卡点</span>
					</div>
					<input type="hidden" value="${us.share_count}" id="sc">
					<input type="hidden" value="${share.total_count}" id="tc">	
					<input type="hidden" value="${check}" id="cp1">
					<input type="hidden" value="${message}" id="message">
					<c:if test="${us.share_count ne null}">
					<c:if test="${us.share_count eq share.total_count or us.share_count gt share.total_count}">
					<div class="claimBox">
						<span class="textC">您有<span class="textKa">${check}<c:if test="${share.presenter_count eq null}">0</c:if></span>个卡点可以认领</span><a class="btnClaim" href="${ctx}/takeSharePoint/${shopid}-${openid}" data-ajax="false">认领</a>
					</div>
					</c:if>
					</c:if>
					<div class="clear10"></div>
					<div class="heapBox">已累积<span class="textBlueKa">${us.share_count}<c:if test="${us.share_count eq null}">0</c:if></span><span class="textGray">/${share.total_count}<c:if test="${share.total_count eq null}">0</c:if></span>个分享</div>
					<p class="heapLine">每天最多可以分享${share.day_count}<c:if test="${share.day_count eq null}">0</c:if>次，您今天已分享${us.day_share_count}<c:if test="${us.day_share_count eq null}">0</c:if>次。</p>
					<p class="heapLine" style="color: red;"><c:if test="${share eq null && praise.day_count eq null}">店家未设置分享功能</c:if></p>
				<div class="btnArea">
					<c:if test="${share ne null && share.day_count ne null}"><a class="btnShare" href="#popupMenu" data-rel="popup" data-transition="pop" id="onMenuShareTimeline">分&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;享</a></c:if>
				</div>
            </div>
            <!--content结束-->
			<!--footer开始-->
            <div id="footer" class="uf c-m2 c-bla t-wh">
            </div>
            <!--footer结束-->
        </div>
<div data-role="popup" id="popupMenu" class="ui-content" data-theme="b" style="max-width:280px">
    <a href="#" data-rel="back" class="ui-btn ui-corner-all ui-shadow ui-btn-a ui-icon-delete ui-btn-icon-notext ui-btn-right">Close</a>
<p>点击右上角，发送给好友或者分享到朋友圈，即可获得卡点。</p>
</div>

</div>

</body> 
<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
<script type="text/javascript">
 /*
  * 注意：
  * 1. 所有的JS接口只能在公众号绑定的域名下调用，公众号开发者需要先登录微信公众平台进入“公众号设置”的“功能设置”里填写“JS接口安全域名”。
  * 2. 如果发现在 Android 不能分享自定义内容，请到官网下载最新的包覆盖安装，Android 自定义分享接口需升级至 6.0.2.58 版本及以上。
  * 3. 常见问题及完整 JS-SDK 文档地址：http://mp.weixin.qq.com/wiki/7/aaa137b55fb2e0456bf8dd9148dd613f.html
  *
  * 开发中遇到问题详见文档“附录5-常见错误及解决办法”解决，如仍未能解决可通过以下渠道反馈：
  * 邮箱地址：weixin-open@qq.com
  * 邮件主题：【微信JS-SDK反馈】具体问题
  * 邮件内容说明：用简明的语言描述问题所在，并交代清楚遇到该问题的场景，可附上截屏图片，微信团队会尽快处理你的反馈。
  */
  wx.config({
	  debug: false,
	    appId: 'wx25d8154f7a1cd8a7',
	    timestamp: 1419835025,
	    nonceStr: '82693e11-b9bc-448e-892f-f5289f46cd0f',
	    signature: '<%=signature %>',
 jsApiList: [
		'checkJsApi',
		'onMenuShareTimeline',
		'onMenuShareAppMessage'
 ]
});
wx.ready(function () {
	  // 2.2 监听“分享到朋友圈”按钮点击、自定义分享内容及分享结果接口
	  //document.querySelector('#onMenuShareTimeline').onclick = function () {
	    wx.onMenuShareTimeline({
	      title: '<%=shopname %>',
	      desc: '我分享的店铺', // 分享描述
	      link: "http://dyywx.shijun.org/kakawx/shopShare/"+$("#shopid").val()+"-"+$("#openid").val(),
	      imgUrl: '<%=serverUrl %>'+'<%=shopimage %>',
	      trigger: function (res) {
	    	 // showDialog('用户点击分享到朋友圈');
	      },
	      success: function (res) {
	    	  alert("分享成功！");
	      },
	      cancel: function (res) {
	    	  
	      },
	      fail: function (res) {
	    	  alert("分享失败！");
	      }
	    });
	    wx.onMenuShareAppMessage({
	        title: '<%=shopname %>', // 分享标题
	        desc: '我分享的店铺', // 分享描述
	        link: "http://dyywx.shijun.org/kakawx/shopShare/"+$("#shopid").val()+"-"+$("#openid").val(), // 分享链接
	        imgUrl: '<%=serverUrl %>'+'<%=shopimage %>', // 分享图标
	        success: function () { 
	        	alert("发送成功！");
	           // 用户确认分享后执行的回调函数
	        },
	        cancel: function () { 
	        }
	    });	    
	    //alert('请点击右上角的分享到朋友圈进行分享');
	 // };
});
wx.error(function (res) {

});
</script>
</html>
